/** @format */

import axios, {AxiosRequestConfig} from '../../src/index';

// 请求拦截器
axios.interceptors.request.use((config: AxiosRequestConfig) => {
  config.headers.test += '1';
  return config;
});

axios.interceptors.request.use((config: AxiosRequestConfig) => {
  config.headers.test += '2';
  return config;
});

// 响应拦截器
axios.interceptors.response.use(res => {
  res.data += '1';
  return res;
});

const responseInterceptorId = axios.interceptors.response.use(res => {
  res.data += '2';
  return res;
});

axios.interceptors.response.use(res => {
  res.data += '3';
  return res;
});

axios.interceptors.response.eject(responseInterceptorId);

axios
  .get('/interceptor/get', {
    headers: {
      test: 'test',
    },
  })
  .then(res => {
    console.log(res);
  });
